#ifndef COMMON_H
#define COMMON_H

#include "dbpath.h"

#include <QThread>
#include <QTimer>
#include <QFile>
#include <QString>
#include <QQueue>
#include <QDateTime>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>

#include <string>
#include <cstring>

using namespace std;

#define cn(x) QString::fromLocal8Bit(x)
#define EPSILON                         0.0000000001

constexpr auto a                        = 6378245.0;
constexpr auto ee                       = 0.00669342162296594323;
constexpr auto PI                       = 3.14159265;
constexpr auto EARTH_RADIUS             = 6378.137;
constexpr auto CAMERA_PORT              = 8000;
constexpr auto CAMERA_USERNAME          = "admin";
constexpr auto CAMERA_IP_ADDR           = "192.168.8.110";

constexpr auto LOGIN_URL                = "https://collection.shtongluyun.com/api/v1/auth/login";
constexpr auto ELEC_FENCE_URL           = "https://collection.shtongluyun.com/api/v1/data/interact/getDeviceEnclosure";
constexpr auto DEVICE_ONLINE_URL        = "https://collection.shtongluyun.com/api/v1/data/interact/inDeviceUpAndDownLineInfo";
constexpr auto GET_VIDEO_STATUS_URL     = "https://collection.shtongluyun.com/api/v1/data/interact/getDeviceVideoStatus";
constexpr auto GPS_UPLOAD_URL           = "https://collection.shtongluyun.com/api/v1/data/collection/inGps";
constexpr auto IRI_UPLOAD_URL           = "https://collection.shtongluyun.com/api/v1/data/collection/inIri";
constexpr auto JUMP_UPLOAD_URL          = "https://collection.shtongluyun.com/api/v1/data/collection/inAbnormalJumps";
constexpr auto CAMERAPIC_UPLOAD_URL     = "https://collection.shtongluyun.com/api/v1/data/collection/inFrontBackCamera";
constexpr auto LAND_SLIDE_SNAP_URL      = "https://collection.shtongluyun.com/api/v1/data/collection/inLandslideSnap";
constexpr auto FRONT_DISEASE_URL        = "https://collection.shtongluyun.com/api/v1/data/collection/inEdgeDisease";
constexpr auto SIGNAGE_UPLOAD_URL       = "https://collection.shtongluyun.com/api/v1/data/collection/inSignage";
constexpr auto TRAFFIC_UPLOAD_URL       = "https://collection.shtongluyun.com/api/data/collection/inTlcTrafficSafety";
constexpr auto CALIBRATION_UPLOAD_URL   = "https://collection.shtongluyun.com/api/v1/data/calibration/inImage";
constexpr auto CALIBRATION_INFO_URL     = "https://videomini.shanghaitonglucloud.com/api/CalibrationFrontCameraChessBoard/calibration";
constexpr auto CALIBRATION_CONFIRM_URL  = "https://videomini.shanghaitonglucloud.com/api/CalibrationFrontCameraChessBoard/confirm";
constexpr auto GET_UPGRADE_DESC_URL     = "http://collection.shtongluyun.com:812/upgrade/upgradeDesc/Lukede4.0/ota_desc.json";

constexpr auto COLLECT_DATA_DIR         = "/home/nvidia/data/Hardware/";
constexpr auto COLLECT_LOG_DIR          = "/home/nvidia/data/Hardware/log/";

typedef struct _POSITION
{
    double longitude;
    double latitude;
} POSITION;

typedef struct
{
    QString sql_id;
    QString dm_data_company_id;
    QString road_type;
    QString device_id;
    QString collect_time;
    QString srcpic_dir;
    QString respic_dir;
    QString picture_name;
    QString longitude;
    QString latitude;
    QString speed;
    QString azimuth;
    QString res;
    QString algorithm_time;
    QString camera_type;
    QString autoApproval;
    QString gcjDamage;
    QString picResolution;
    QString sceneId;
    QString cameraAntennaAngle;
    QString cameraDistance;
    QString cameraVehicleAngle;
    QString gpsStatus;
    QString pitch;
} DISEASE_INFO;

extern DBPath m_db_path;

#endif // COMMON_H
